home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / buffr2.zip / BD3_MAX.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  3KB  |  110 lines

  1. Unit BD3_Max; {Primitive 3-Dimensional BufferedArrays}
  2. {$R-}
  3.  
  4. INTERFACE
  5.  
  6. Uses BND_Max;
  7.  
  8. Type
  9.  
  10.   D3_BufferedArray = Object (BN_Max)
  11.  
  12.                    Procedure Init (ElementsPerDimension : DimensionPtr;
  13.                                   ElementSize : Word; MaxBuffSize : LongInt;
  14.                                   FileName : String);
  15.  
  16.                    Procedure Accept (X,Y,Z : LongInt; Var El; Size : Word);
  17.                                        {Assign the Addressed El}
  18.  
  19.                    Procedure Retrieve (X,Y,Z : LongInt; Var El; Size : Word);
  20.                                          {Get the Addressed El}
  21.  
  22.  
  23.                    Procedure Swap (X1,Y1,Z1,X2,Y2,Z2 : LongInt);
  24.                               {Swap the 1 and 2 Element}
  25.  
  26.                    Procedure Copy (From : D3_BufferedArray);
  27.                               {Target *MUST* already be initialized}
  28.                               {to the EXACT same parameters as From}
  29.                               {this will save checking for sufficient}
  30.                               {available Memory!}
  31.  
  32. (* no redefinition needed
  33.  
  34.  
  35.                    Function MaxIndex (Index : Byte) : LongInt;
  36.                                      {Return the Max legal Index}
  37.                                      {for the Indexth Dimension}
  38.  
  39.                    Function MaxSize : LongInt;
  40.                                       {Report Total Number of Array Elements}
  41.  
  42.                    Function ElemSize : Word;  {Report Element Size}
  43.  
  44.                    Procedure Destroy;
  45. *)
  46.           End; {D3_BufferedArray}
  47.  
  48.  
  49.  
  50. IMPLEMENTATION
  51.  
  52.  
  53. Procedure D3_BufferedArray.Init;
  54. Begin
  55.   BN_Max.Init (3,ElementsPerDimension,ElementSize,MaxBuffSize,FileName)
  56. End;
  57.  
  58. Procedure D3_BufferedArray.Accept (X,Y,Z : LongInt; Var El; Size : Word);
  59.                                        {Assign the Addressed El}
  60. Var
  61.   I : Byte;
  62. Begin
  63.   I := 0;
  64.   Add1^[I] := X;  {even with range-checking off, the}
  65.   I := 1;
  66.   Add1^[I] := Y;  {compiler generates an error if}
  67.   I := 2;         {a constant is used here. Dunno why...}
  68.   Add1^[I] := Z;
  69.   BN_Max.Accept (El,Add1,3,Size)
  70. End;
  71.  
  72. Procedure D3_BufferedArray.Retrieve (X,Y,Z : LongInt; Var El; Size : Word);
  73.                                          {Get the Addressed El}
  74. Var
  75.   I : Byte;
  76. Begin
  77.   I := 0;
  78.   Add1^[I] := X;
  79.   I := 1;
  80.   Add1^[I] := Y;
  81.   I := 2;
  82.   Add1^[I] := Z;
  83.   BN_Max.Retrieve (El,Add1,3,Size)
  84. End;
  85.  
  86. Procedure D3_BufferedArray.Swap (X1,Y1,Z1,X2,Y2,Z2 : LongInt);
  87.                               {Swap the 1 and 2 Element}
  88. Var
  89.   I : Byte;
  90. Begin
  91.   I := 0;
  92.   Add1^[I] := X1;
  93.   Add2^[I] := X2;
  94.   I := 1;
  95.   Add1^[I] := Y1;
  96.   Add2^[I] := Y2;
  97.   I := 2;
  98.   Add1^[I] := Z1;
  99.   Add2^[I] := Z2;
  100.   BN_Max.Swap (Add1,Add2,3)
  101. End;
  102.  
  103. Procedure D3_BufferedArray.Copy (From : D3_BufferedArray);
  104. {Redefined purely for type-checking}
  105. Begin
  106.   BN_Max.Copy (From)
  107. End;
  108.  
  109. BEGIN
  110. END.